﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace WgFrame.Net
{
    public class MessageBufferPool
    {
        private Queue<StreamBuffer> pool = new Queue<StreamBuffer>(32);


        public StreamBuffer Get()
        {
            lock (pool)
            {
                return ((pool.Count <= 0) ? new StreamBuffer(75) : pool.Dequeue());
            }
        }

        public void Put(StreamBuffer buff)
        {
            buff.Position = 0;
            buff.SetLength(0L);
            lock (pool)
            {
                pool.Enqueue(buff);
            }
        }
    }
}
